package com.djf.eg.auth;

import org.apache.shiro.crypto.hash.Md5Hash;
import org.apache.shiro.crypto.hash.SimpleHash;
import org.apache.shiro.util.ByteSource;

public class DCryptography {
	
	public static String algorithmName = Md5Hash.ALGORITHM_NAME;
	
	public static String salt = "djf_eg_rfxq";
	
	public static int hashIterations = 10;
	
	public static String encryptPassword(String value, String username) {
        return encrypt(value, DCryptography.salt+username);
    }
	
	public static String encrypt(String value, String salt) {
        return new SimpleHash(algorithmName, value, ByteSource.Util.bytes(salt), hashIterations).toHex();
    }
	
	public static String encrypt(String value) {
        return encrypt(value, salt);
    }
	
}
